<%--
  Created by IntelliJ IDEA.
  User: xierongxian
  Date: 2016/3/31
  Time: 16:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"  %>

<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>我的地址</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <!-- <link rel="shortcut icon" href="/favicon.ico"> -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="<%=basePath %>/resources/Public/Vendor/SUI/dist/css/sm.min.css">

    <link rel="stylesheet" href="<%=basePath %>/resources/Public/Vendor/SUI/dist/css/sm.min.css">
    <link rel="stylesheet" href="<%=basePath %>/resources/Public/Vendor/SUI/dist/css/sm-extend.min.css">
    <link rel="stylesheet" type="text/css" href="<%=basePath %>/resources/Public/Vendor/icon/iconfont.css">

    <link rel="stylesheet" href="<%=basePath %>/resources/Public/css/common.css">

</head>
<body>
<div class="page-group">
    <div class="page xgj-addAdress-list" id='xgj-addAdress-list'>
        <div class="content ">
            <div class="list-block">
                <ul>
                    <c:if test="${not empty addresss}">

                <c:forEach items="${addresss}" var="ad">
                    <li>
                        <div class="item-content">
                            <div class="row no-gutter">
                                <p>
                                    <span>收货人&nbsp;&nbsp;&nbsp;：</span>
                                    <span>${ad.uName}</span>
                                </p>
                                <p>
                                    <span>联系电话：</span>
                                    <span>${ad.aphone}</span>
                                </p>
                                <p>
                                    <span>收货地址：</span>
                                    <span>${ad.aname}</span>
                                </p>
                            </div>
                        </div>

                        <div class="divier"></div>
                        <div class="item-address-btm">
                            <div class="pull-left  adress-defult-active">
                                <label for="adress-defult">
                                    <input name="adress-defult" class="address-defult" value="${ad.id}" checked="<c:if test="${ad.defaultAddress==true}">checked</c:if>
                            "type="radio"  />
                                    <span>默认地址</span>
                                </label>

                            </div>
                            <div class="pull-right">
                                <input type="hidden" data-id="${ad.id}" value="${ad.id}">
                                <a href="<%=basePath %>wx/add/address_edit.do?id=${ad.id}" class="address-del-edit">编辑</a>
                                <a href="javascript:void(0)" class="address-del-btn">删除</a>
                            </div>
                        </div>
                        <div style="clear:both;"></div>
                    </li>
                    </c:forEach>
                    </c:if>
                    <c:if test="${empty addresss}">
                    <div class="content-block no-order" >
                        <span class="icon iconfont icon-dingdan1"></span>
                        <span class="tab-label">您还未添加服务地址，请添加服务地址</span>
                    </div>
                    </c:if>
            </div>

        </div>
        <nav class="bar bar-tab xgj-bar-btn">
            <p><a href="<%=basePath %>wx/add/address_add.do" class="">新增地址</a></p>
        </nav>
    </div>
    <!--   此处引入 _footer.html -->
    <script src='<%=basePath %>/resources/Public/Vendor/SUI/dist/js/zepto.js'></script>
    <script type="text/javascript">
        $.config = {
            // 路由功能开关过滤器，返回 false 表示当前点击链接不使用路由
            routerFilter: function($link) {
                // 某个区域的 a 链接不想使用路由功能
                if ($link.is('.disable-router a')) {
                    return false;
                }
                return true;
            }
        };
    </script>
    <script src='<%=basePath %>/resources/Public/Vendor/SUI/dist/js/sm.js'></script>
    <script src="<%=basePath %>/resources/Public/Vendor/SUI/dist/js/sm-city-picker.min.js" ></script>
    <script src='<%=basePath %>/resources/Public/Vendor/SUI/dist/js/sm-extend.min.js'></script>

    <!-- / 此处引入 _footer.html -->
    <script type="text/javascript">

        $(".address-del-btn").on('click',function () {
            var addressId=$(this).parent('div').find('input').attr('data-id');
            $.confirm('确认删除该地址?',
                function () {
                    $.ajax({
                        url: "<%=path%>/wx/add/delAddress.do",
                        method: 'POST',
                        dataType: 'json',
                        data: {
                            id: addressId
                        },
                        success: function(data){
                            if(data.result=="0000"){
                                window.location.reload();
                            }else{
                                $.toast("删除失败");
                            }
                        }
                    });
                }

            );
        })

        $(".address-defult").on('click',function () {
            var addressId=$(this).val();
            $.ajax({
                url: "<%=path%>/wx/add/defaultAddress.do",
                method: 'GET',
                dataType: 'json',
                data: {
                    id: addressId
                },
                success: function(data){
                    if(data.result=="0000"){

                    }
                },error:function(e){
                    alert(e);
                }
            });

        })



    </script>

</body>
</html>